package com.wl.zlmanage.controller;

import com.wl.zlmanage.bean.ApprovalInfo;
import com.wl.zlmanage.bean.BSType;
import com.wl.zlmanage.bean.ExpendInfo;
import com.wl.zlmanage.bean.MatchedQyInfo;
import com.wl.zlmanage.bean.Notice;
import com.wl.zlmanage.bean.SignTypeInfo;
import com.wl.zlmanage.bean.User;
import com.wl.zlmanage.bean.ZlInfo;
import com.wl.zlmanage.bean.ZlSignInfo;
import com.wl.zlmanage.constant.ActivityConstant;
import com.wl.zlmanage.mapper.ApplyMapper;
import com.wl.zlmanage.mapper.ResourceMapper;
import com.wl.zlmanage.mapper.SignCustomMapper;
import com.wl.zlmanage.mapper.UserMapper;
import com.wl.zlmanage.utils.TimeUtils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by wanglei on 2018/5/25.
 */
@Controller
public class ZlInfoController {

    public static Map<Integer, List<SignTypeInfo>> signTypeMap = new HashMap<>();

    private Logger logger = LoggerFactory.getLogger(ZlInfoController.class);

    @Autowired
    ResourceMapper resourceDao;

    @Autowired
    SignCustomMapper signCustomDao;

    @Autowired
    ApplyMapper applyDao;

    @Autowired
    UserMapper userDao;

    @RequestMapping("/getResource.do")
    @ResponseBody
    public Map<String, Object> getResource(HttpServletRequest request, HttpSession session,
        @RequestParam("page") int page,
        @RequestParam("limit") int limit, @RequestParam("search") String search) {
        Map<String, Object> resultMap = new HashMap<String, Object>();
        Integer userId = (Integer) session.getAttribute("userId");
        String username = (String) session.getAttribute("username");
        User user = userDao.getUserById(username);
        int startIndex = (page - 1) * limit;
        Integer type = 1;
        if (ActivityConstant.deptList.contains(user.getUserDept()) || user.getUserDept() == 100) {
            type = 2;
        }else if(0 == user.getUserDept()){
            type = 0;
        }
        ExpendApprovalController.initChildDept(user);
        List<ZlInfo> reList = resourceDao.getResourceList(user, startIndex, limit, search, type);
        Integer count = resourceDao.getResourceListCount(user, search, type);
        resultMap.put("data", reList);
        resultMap.put("count", count);
        resultMap.put("code", 0);
        resultMap.put("msg", "");
        return resultMap;
    }

    @RequestMapping("/saveResource.do")
    @ResponseBody
    public String saveResource(HttpSession session, ZlInfo zlInfo) {
        Integer userId = (Integer) session.getAttribute("userId");
        Integer deptNo = userDao.getUserDept(userId);
        Integer type = 1;
        if (ActivityConstant.deptList.contains(deptNo)) {
            type = 2;
        }else if(0 == deptNo){
            type = 0;
        }
        zlInfo.setType(type);
        zlInfo.setCreateUserId(userId);
        zlInfo.setCreateTime(TimeUtils.getCurrentDateString(TimeUtils.DATE_TIME_FORMAT));
        resourceDao.saveResource(zlInfo);
        return "success";
    }

    @RequestMapping("/deleteResourceById.do")
    @ResponseBody
    public String deleteResourceById(Integer resourceId) {
        resourceDao.deleteResourceById(resourceId);
        return "success";
    }

    @RequestMapping("/getResourceById.do")
    @ResponseBody
    public ZlInfo getResourceById(Integer resourceId) {
        ZlInfo zlInfo = resourceDao.getResourceById(resourceId);
        return zlInfo;
    }

    @RequestMapping("/updateResourceMark.do")
    @ResponseBody
    public String updateResourceMark(ZlInfo zlInfo) {
        resourceDao.updateResourceMark(zlInfo);
        return "success";
    }


    @RequestMapping("/getSignCustom.do")
    @ResponseBody
    public Map<String, Object> getSignCustom(HttpSession session, @RequestParam("page") int page,
        @RequestParam("limit") int limit, @RequestParam("search") String search,
        @RequestParam("signType") int signType) {
        Map<String, Object> resultMap = new HashMap<String, Object>();
        Integer userId = (Integer) session.getAttribute("userId");
        String username = (String) session.getAttribute("username");
        int startIndex = (page - 1) * limit;
        User user = userDao.getUserById(username);
        int approvalState = user.getRoleId();
        List<ZlSignInfo> reList = signCustomDao
            .getSignCustomList(userId, startIndex, limit, search, approvalState, user.getUserDept(),
                signType);
        Integer count = signCustomDao
            .getSignCustomListCount(userId, startIndex, limit, search, approvalState,
                user.getUserDept(), signType);
        resultMap.put("data", reList);
        resultMap.put("count", count);
        resultMap.put("code", 0);
        resultMap.put("msg", "");
        return resultMap;
    }

    @RequestMapping("/getAllBigType.do")
    @ResponseBody
    public List<BSType> getAllBigType() {
        List<BSType> resultList = signCustomDao.getAllBigType();
        return resultList;
    }

    @RequestMapping("/getAllSmallType.do")
    @ResponseBody
    public List<BSType> getAllSmallType(@RequestParam("parentId") int parentId) {
        List<BSType> resultList = signCustomDao.getAllSmallType(parentId);
        return resultList;
    }

    @RequestMapping("/saveSign.do")
    @ResponseBody
    public String saveSign(HttpSession session, ZlSignInfo zlSignInfo, String qyFlag) {
        Integer userId = (Integer) session.getAttribute("userId");
        zlSignInfo.setCreateUserId(userId);
        zlSignInfo.setCreateTime(TimeUtils.getCurrentDateString(TimeUtils.DATE_DAY_FORMAT));
        zlSignInfo.setApprovalState(0);
        signCustomDao.saveSign(zlSignInfo);
        if (zlSignInfo.getId() > 0 && null != qyFlag) {
            List<SignTypeInfo> signTypeInfoList = signTypeMap.get(userId);
            if (null == signTypeInfoList) {
                signTypeInfoList = new ArrayList<>();
            }
            for (SignTypeInfo st : signTypeInfoList) {
                st.setSignId(zlSignInfo.getId());
            }
            signCustomDao.saveSignType(signTypeInfoList);
            initSignTypeMap(session);
        }
        return "success";
    }

    @RequestMapping("/askApproval.do")
    @ResponseBody
    public String askApproval(HttpSession session, @RequestParam("signId") int signId,
        @RequestParam("approvalState") int approvalState) {
        Integer result = signCustomDao.askApproval(signId, approvalState + 1);
        if (result > 0) {
            Integer userId = (Integer) session.getAttribute("userId");
            ApprovalInfo ai = new ApprovalInfo();
            ai.setApprovalResult(ActivityConstant.APPROVAL_START);
            ai.setApprovalAdvice(ActivityConstant.APPROVAL_NULL);
            ai.setApprovalUserId(userId);
            ai.setSignId(signId);
            ai.setApprovalTime(TimeUtils.getCurrentDateString(TimeUtils.DATE_TIME_FORMAT));

            signCustomDao.saveApprovalInfo(ai);
        }
        return "success";
    }

    @RequestMapping("/doApproval.do")
    @ResponseBody
    public String doApproval(HttpSession session, @RequestParam("signId") int signId,
        @RequestParam("approvalState") int approvalState,
        @RequestParam("approvalResult") int approvalResult,
        @RequestParam("approvalAdvice") String approvalAdvice) {
        Integer userId = (Integer) session.getAttribute("userId");
        String nowTime = TimeUtils.getCurrentDateString(TimeUtils.DATE_TIME_FORMAT);
        if (approvalResult == 1) {
            approvalState += 1;
            signCustomDao.askApproval(signId, approvalState);
            if (approvalState + 1 == 4) {
                List<Notice> reNoticeList = new ArrayList<>();
                Notice notice = null;
                ZlSignInfo zlSignInfo = signCustomDao.getSignById(signId);
                if (zlSignInfo.getSignType() == 1) {
                    notice = new Notice();
                    notice.setContent(
                        "签约客户:<span style='color:#FF5722;'>" + zlSignInfo.getName()
                            + "</span>审批完成，大类：" + zlSignInfo.getBigType()
                            + "，小类：" + zlSignInfo.getSmallType());
                    notice.setCreateTime(nowTime);
                    reNoticeList.add(notice);
                } else {
                    List<SignTypeInfo> signTypeList = signCustomDao.getSignTypeBySignId(signId);
                    for (SignTypeInfo signTypeInfo : signTypeList) {
                        notice = new Notice();
                        notice.setContent(
                            "签约企业:<span style='color:red;'>" + zlSignInfo.getName()
                                + "</span>审批完成，需要证书：大类：" + signTypeInfo.getBigType()
                                + "，小类：" + signTypeInfo.getSmallType() + "(需求：" + signTypeInfo
                                .getPeopleNum() + "本)");
                        notice.setCreateTime(nowTime);
                        reNoticeList.add(notice);
                    }
                }
                signCustomDao.saveNotice(reNoticeList);

            }
        } else {
            signCustomDao.askApproval(signId, 0);
        }
        String approvalResultStr = ActivityConstant.APPROVAL_PASS;
        if (approvalResult == 0) {
            approvalResultStr = ActivityConstant.APPROVAL_BACK;
        }

        ApprovalInfo ai = new ApprovalInfo();
        ai.setApprovalResult(approvalResultStr);
        ai.setApprovalAdvice(approvalAdvice);
        ai.setApprovalUserId(userId);
        ai.setSignId(signId);
        ai.setApprovalTime(nowTime);

        signCustomDao.saveApprovalInfo(ai);

        return "success";
    }

    @RequestMapping("/getApprovalBySignId.do")
    @ResponseBody
    public List<ApprovalInfo> getApprovalBySignId(@RequestParam("signId") int signId) {
        List<ApprovalInfo> reList = signCustomDao.getApprovalBySignId(signId);
        return reList;
    }

    @RequestMapping("/getSignById.do")
    @ResponseBody
    public ZlSignInfo getSignById(@RequestParam("signId") int signId) {
        ZlSignInfo zlSignInfo = signCustomDao.getSignById(signId);
        return zlSignInfo;
    }

    @RequestMapping("/editSign.do")
    @ResponseBody
    public String editSign(HttpSession session, ZlSignInfo zlSignInfo, Integer signId) {
        zlSignInfo.setId(signId);
        signCustomDao.editSign(zlSignInfo);
        return "success";
    }

    @RequestMapping("/editQySign.do")
    @ResponseBody
    public String editQySign(HttpSession session, ZlSignInfo zlSignInfo, Integer signId) {
        zlSignInfo.setApprovalState(0);
        zlSignInfo.setId(signId);
        signCustomDao.editQySign(zlSignInfo);
        return "success";
    }

    @RequestMapping("/deleteSignById.do")
    @ResponseBody
    public String deleteSignById(Integer signId) {
        Integer result = signCustomDao.deleteSignById(signId);
        if (result > 0) {
            signCustomDao.deleteApprovalInfo(signId);
            signCustomDao.deleteAllSignType(signId);
            signCustomDao.deleteAllExpend(signId);
        }
        return "success";
    }

    @RequestMapping("/getExpend.do")
    @ResponseBody
    public Map<String, Object> getExpend(@RequestParam("page") int page,
        @RequestParam("limit") int limit, @RequestParam("signId") int signId) {
        Map<String, Object> resultMap = new HashMap<String, Object>();
        int startIndex = (page - 1) * limit;
        List<ExpendInfo> reList = signCustomDao.getExpend(signId, startIndex, limit);
        Integer count = signCustomDao.getExpendCount(signId, startIndex, limit);
        resultMap.put("data", reList);
        resultMap.put("count", count);
        resultMap.put("code", 0);
        resultMap.put("msg", "");
        return resultMap;
    }

    @RequestMapping("/addExpendInfo.do")
    @ResponseBody
    public String addExpendInfo(ExpendInfo expendInfo, HttpSession session) {
        String nowTime = TimeUtils.getCurrentDateString(TimeUtils.DATE_MONTH_FORMAT_SQL);
        String createTime = TimeUtils.getCurrentDateString(TimeUtils.DATE_TIME_FORMAT);
        expendInfo.setExpendTime(nowTime);
        expendInfo.setCreateTime(createTime);
        if(null != expendInfo && ActivityConstant.KD.equals(expendInfo.getExpendType())){
            expendInfo.setExpendStatus(8);
        } else {
            expendInfo.setExpendStatus(1);
        }

        signCustomDao.addExpendInfo(expendInfo);

        if (null != expendInfo && expendInfo.getId() > 0) {
            Integer userId = (Integer) session.getAttribute("userId");
            ApprovalInfo ai = new ApprovalInfo();
            ai.setApprovalResult(ActivityConstant.APPROVAL_START);
            ai.setApprovalAdvice(ActivityConstant.APPROVAL_NULL);
            ai.setApprovalUserId(userId);
            ai.setSignId(expendInfo.getId());
            ai.setApprovalTime(TimeUtils.getCurrentDateString(TimeUtils.DATE_TIME_FORMAT));

            applyDao.saveExpendApprovalInfo(ai);
        }
        return "success";
    }

    @RequestMapping("/addExpendInfoNew.do")
    @ResponseBody
    public String addExpendInfoNew(ExpendInfo expendInfo, HttpSession session) {
        Integer userId = (Integer) session.getAttribute("userId");
        String username = (String) session.getAttribute("username");
        String nowTime = TimeUtils.getCurrentDateString(TimeUtils.DATE_MONTH_FORMAT_SQL);
        String createTime = TimeUtils.getCurrentDateString(TimeUtils.DATE_TIME_FORMAT);
        User user = userDao.getUserById(username);
        expendInfo.setExpendStatus(8);
        expendInfo.setUserId(userId);
        expendInfo.setExpendTime(nowTime);
        expendInfo.setCreateTime(createTime);
        Integer signType = 1;
        if (ActivityConstant.deptList.contains(user.getUserDept())) {
            signType = 2;
        }
        expendInfo.setSignType(signType);
        signCustomDao.addExpendInfoNew(expendInfo);

        if (null != expendInfo && expendInfo.getId() > 0) {
            ApprovalInfo ai = new ApprovalInfo();
            ai.setApprovalResult(ActivityConstant.APPROVAL_START);
            ai.setApprovalAdvice(ActivityConstant.APPROVAL_NULL);
            ai.setApprovalUserId(userId);
            ai.setSignId(expendInfo.getId());
            ai.setApprovalTime(TimeUtils.getCurrentDateString(TimeUtils.DATE_TIME_FORMAT));

            applyDao.saveExpendApprovalInfoNew(ai);
        }
        return "success";
    }

    @RequestMapping("/deleteExpend.do")
    @ResponseBody
    public String deleteExpend(@RequestParam("expendId") int expendId) {
        signCustomDao.deleteExpend(expendId);
        return "success";
    }

    @RequestMapping("/getAllExpend.do")
    @ResponseBody
    public Double getAllExpend(@RequestParam("signId") int signId) {
        Double tatal = signCustomDao.getExpendTatal(signId);
        return tatal;
    }

    @RequestMapping("/getSignType.do")
    @ResponseBody
    public Map<String, Object> getSignType(HttpServletRequest request, HttpSession session,
        @RequestParam("page") int page,
        @RequestParam("limit") int limit, @RequestParam("signId") Integer signId) {
        Map<String, Object> resultMap = new HashMap<String, Object>();
        Integer userId = (Integer) session.getAttribute("userId");
        int startIndex = (page - 1) * limit;
        List<SignTypeInfo> reList = null;
        Integer count = 0;
        if (null == signId) {
            List<SignTypeInfo> allList = signTypeMap.get(userId);
            if (null == allList) {
                count = 0;
                reList = new ArrayList<>();
            } else {
                count = allList.size();
                int end = startIndex + limit;
                if (end > allList.size()) {
                    end = allList.size();
                }
                Collections.reverse(allList);
                reList = allList.subList(startIndex, end);
            }

        } else {
            reList = signCustomDao.getSignType(signId, startIndex, limit);
            count = signCustomDao.getSignTypeCount(signId);
        }
        resultMap.put("data", reList);
        resultMap.put("count", count);
        resultMap.put("code", 0);
        resultMap.put("msg", "");
        return resultMap;
    }

    @RequestMapping("/addSignTypeTemp.do")
    @ResponseBody
    public String addSignTypeTemp(HttpSession session, SignTypeInfo signTypeInfo) {
        Integer userId = (Integer) session.getAttribute("userId");
        if (null != signTypeInfo.getSignId()) {
            List<SignTypeInfo> signTypeList = new ArrayList<>();
            signTypeList.add(signTypeInfo);
            signCustomDao.saveSignType(signTypeList);
        } else {
            List<SignTypeInfo> signList = signTypeMap.get(userId);
            if (null == signList) {
                signList = new ArrayList<>();
            }
            signTypeInfo.setId(signList.size());
            signList.add(signTypeInfo);
            signTypeMap.put(userId, signList);
        }
        return "success";
    }

    @RequestMapping("/deleteSignType.do")
    @ResponseBody
    public String deleteSignType(HttpSession session, @RequestParam("signId") Integer signId,
        @RequestParam("signTypeId") Integer signTypeId) {
        Integer userId = (Integer) session.getAttribute("userId");
        if (null != signId) {
            signCustomDao.deleteSignType(signTypeId);
        } else {
            List<SignTypeInfo> signList = signTypeMap.get(userId);
            if (null == signList) {
                signList = new ArrayList<>();
            }
            List<SignTypeInfo> newSignList = new ArrayList<>();
            for (SignTypeInfo st : signList) {
                if (signTypeId != st.getId()) {
                    newSignList.add(st);
                }
            }
            signTypeMap.put(userId, newSignList);
        }
        return "success";
    }

    @RequestMapping("/initSignTypeMap.do")
    @ResponseBody
    public String initSignTypeMap(HttpSession session) {
        Integer userId = (Integer) session.getAttribute("userId");
        signTypeMap.put(userId, new ArrayList<SignTypeInfo>());
        return "success";
    }

    @RequestMapping("/getCanMatchSignCustom.do")
    @ResponseBody
    public Map<String, Object> getCanMatchSignCustom(HttpSession session,
        @RequestParam("page") int page,
        @RequestParam("limit") int limit, @RequestParam("search") String search) {
        Map<String, Object> resultMap = new HashMap<String, Object>();
        int startIndex = (page - 1) * limit;
        int approvalState = 4;
        int signType = 2;
        List<ZlSignInfo> reList = signCustomDao
            .getCanMatchSignCustomList(startIndex, limit, search, approvalState, signType);
        Integer needCount = 0;
        Integer matchCount = 0;
        for (ZlSignInfo zlSignInfo : reList) {
            needCount = signCustomDao.getSignTypeCountNum(zlSignInfo.getId());
            matchCount = signCustomDao.getMatchedSignCount(zlSignInfo.getId());
            zlSignInfo.setNeedCount(needCount);
            zlSignInfo.setMatchCount(matchCount);
        }
        Integer count = signCustomDao
            .getCanMatchSignCustomListCount(search, approvalState, signType);
        resultMap.put("data", reList);
        resultMap.put("count", count);
        resultMap.put("code", 0);
        resultMap.put("msg", "");
        return resultMap;
    }

    @RequestMapping("/getMatchedSignList.do")
    @ResponseBody
    public Map<String, Object> getMatchedSignList(HttpSession session,
        @RequestParam("page") int page,
        @RequestParam("limit") int limit,
        @RequestParam("signId") int signId) {
        Map<String, Object> resultMap = new HashMap<String, Object>();
        int startIndex = (page - 1) * limit;
        List<ZlSignInfo> reList = signCustomDao.getMatchedSignList(startIndex, limit, signId);
        Integer count = signCustomDao.getMatchedSignListCount(signId);
        resultMap.put("data", reList);
        resultMap.put("count", count);
        resultMap.put("code", 0);
        resultMap.put("msg", "");
        return resultMap;
    }

    @RequestMapping("/getCanMatchPersonSignCustom.do")
    @ResponseBody
    public Map<String, Object> getCanMatchPersonSignCustom(HttpSession session,
        @RequestParam("page") int page,
        @RequestParam("limit") int limit, @RequestParam("search") String search) {
        Map<String, Object> resultMap = new HashMap<String, Object>();
        int startIndex = (page - 1) * limit;
        int approvalState = 4;
        int signType = 1;
        List<ZlSignInfo> reList = signCustomDao
            .getCanMatchPersonSignCustomList(startIndex, limit, search, approvalState, signType);
        Integer count = signCustomDao
            .getCanMatchPersonSignCustomListCount(search, approvalState, signType);
        resultMap.put("data", reList);
        resultMap.put("count", count);
        resultMap.put("code", 0);
        resultMap.put("msg", "");
        return resultMap;
    }

    @RequestMapping("/matchPersonSign.do")
    @ResponseBody
    public String matchPersonSign(HttpSession session, @RequestParam("signId") int signId,
        @RequestParam("personSignId") int personSignId,
        @RequestParam("signTypeId") int signTypeId) {
        Map<String, Object> paramMap = new HashMap<String, Object>();
        String matchTime = TimeUtils.getCurrentDateString(TimeUtils.DATE_DAY_FORMAT);
        Integer userId = (Integer) session.getAttribute("userId");
        paramMap.put("matchTime", matchTime);
        paramMap.put("userId", userId);
        paramMap.put("signId", signId);
        paramMap.put("personSignId", personSignId);
        paramMap.put("signTypeId", signTypeId);
        Integer result = signCustomDao.addSignMatchInfo(paramMap);
        if (result > 0) {
            signCustomDao.updateMatchState(personSignId, 1);
        }
        return "success";
    }


    @RequestMapping("/cancelMatchPersonSign.do")
    @ResponseBody
    public String cancelMatchPersonSign(@RequestParam("signId") int signId,
        @RequestParam("personSignId") int personSignId) {
        Integer result = signCustomDao.deleteMatchInfo(signId, personSignId);
        if (result > 0) {
            signCustomDao.updateMatchState(personSignId, 0);
        }
        return "success";
    }

    @RequestMapping("/getMatchedSignApplyList.do")
    @ResponseBody
    public Map<String, Object> getMatchedSignApplyList(HttpSession session,
        @RequestParam("page") int page,
        @RequestParam("limit") int limit,
        @RequestParam("signId") int signId) {
        Map<String, Object> resultMap = new HashMap<String, Object>();
        int startIndex = (page - 1) * limit;
        List<ZlSignInfo> reList = signCustomDao.getMatchedSignList(startIndex, limit, signId);
        Integer count = signCustomDao.getMatchedSignListCount(signId);
        Double sumPrice;
        for (ZlSignInfo zlSignInfo : reList) {
            sumPrice = signCustomDao.getApplySumBySignId(zlSignInfo.getId());
            zlSignInfo.setSumPrice(sumPrice);
        }
        resultMap.put("data", reList);
        resultMap.put("count", count);
        resultMap.put("code", 0);
        resultMap.put("msg", "");
        return resultMap;
    }

    @RequestMapping("/getNoticeListCount.do")
    @ResponseBody
    public Integer getNoticeListCount() {
        Integer count = signCustomDao.getNoticeListCount();
        return count;
    }

    @RequestMapping("/getNoticeList.do")
    @ResponseBody
    public List<Notice> getNoticeList(@RequestParam("page") int page,
        @RequestParam("limit") int limit) {
        int startIndex = (page - 1) * limit;
        List<Notice> reList = signCustomDao.getNoticeList(startIndex, limit);
        return reList;
    }

    @RequestMapping("/stopOverSign.do")
    @ResponseBody
    public String stopOverSign(@RequestParam("signId") int signId,
        @RequestParam("signType") int signType) {
        signCustomDao.stopOverSign(signId);
        if (signType == 1) {

        } else if (signType == 2) {

        }
        return "success";
    }


    @RequestMapping("/getMatchedQyInfo.do")
    @ResponseBody
    public Map<String, Object> getMatchedQyInfo(@RequestParam("signId") int signId) {
        Map<String, Object> resultMap = new HashMap<String, Object>();
        List<MatchedQyInfo> reList = signCustomDao.getMatchedQyInfo(signId);
        Integer count = 1;
        resultMap.put("data", reList);
        resultMap.put("count", count);
        resultMap.put("code", 0);
        resultMap.put("msg", "");
        return resultMap;
    }

    @RequestMapping("/getMatchedPersonList.do")
    @ResponseBody
    public Map<String, Object> getMatchedPersonList(@RequestParam("signId") int signId,
        @RequestParam("page") int page,
        @RequestParam("limit") int limit) {
        Map<String, Object> resultMap = new HashMap<String, Object>();
        int startIndex = (page - 1) * limit;
        List<ZlSignInfo> reList = signCustomDao.getMatchedPersonList(signId, startIndex, limit);
        Integer count = signCustomDao.getMatchedPersonListCount(signId);
        resultMap.put("data", reList);
        resultMap.put("count", count);
        resultMap.put("code", 0);
        resultMap.put("msg", "");
        return resultMap;
    }

    @RequestMapping("/getSignCustomById.do")
    @ResponseBody
    public Map<String, Object> getSignCustomById(@RequestParam("id") Integer id) {
        Map<String, Object> resultMap = new HashMap<String, Object>();
        List<ZlSignInfo> reList = signCustomDao.getSignCustomById(id);
        resultMap.put("data", reList);
        resultMap.put("count", 0);
        resultMap.put("code", 0);
        resultMap.put("msg", "");
        return resultMap;
    }

}
